﻿using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using Teigha.Core;

namespace Teigha.TD
{
	public class OdDbPaperOrientationPE : OdRxObject
	{
		[EditorBrowsable(EditorBrowsableState.Never)]
		public OdDbPaperOrientationPE(IntPtr cPtr, bool cMemoryOwn) : base(TD_DbPINVOKE.OdDbPaperOrientationPE_SWIGUpcast(cPtr), cMemoryOwn)
		{
			this.swigCPtr = new HandleRef(this, cPtr);
		}

		[EditorBrowsable(EditorBrowsableState.Never)]
		public static HandleRef getCPtr(OdDbPaperOrientationPE obj)
		{
			if (obj != null)
			{
				return obj.swigCPtr;
			}
			return new HandleRef(null, IntPtr.Zero);
		}

		~OdDbPaperOrientationPE()
		{
			this.Dispose();
		}

		public override void Dispose()
		{
			if (this.swigCPtr.Handle != IntPtr.Zero)
			{
				if (this.swigCMemOwn)
				{
					lock (this.locker)
					{
						if (this.swigCPtr.Handle != IntPtr.Zero && this.swigCMemOwn)
						{
							this.swigCMemOwn = false;
							TD_DbPINVOKE.delete_OdDbPaperOrientationPE(this.swigCPtr);
						}
					}
					this.swigCMemOwn = false;
				}
				this.swigCPtr = new HandleRef(null, IntPtr.Zero);
			}
			GC.SuppressFinalize(this);
			base.Dispose();
		}

		public new static OdDbPaperOrientationPE cast(OdRxObject pObj)
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbPaperOrientationPE_cast(OdRxObject.getCPtr(pObj));
			OdDbPaperOrientationPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new static OdRxClass desc()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPaperOrientationPE_desc(), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxClass isA()
		{
			OdRxClass result = (OdRxClass)Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPaperOrientationPE_isA(this.swigCPtr), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public new virtual OdRxObject queryX(OdRxClass protocolClass)
		{
			OdRxObject result = Teigha.Core.Helpers.odrxCreateObjectInternal(TD_DbPINVOKE.OdDbPaperOrientationPE_queryX(this.swigCPtr, OdRxClass.getCPtr(protocolClass)), false);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public static OdDbPaperOrientationPE createObject()
		{
			MemoryManager memoryManager = MemoryManager.GetMemoryManager();
			MemoryTransaction currentTransaction = memoryManager.GetCurrentTransaction();
			IntPtr p = TD_DbPINVOKE.OdDbPaperOrientationPE_createObject();
			OdDbPaperOrientationPE result;
			if (currentTransaction != null)
			{
				currentTransaction.AddObject((OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true));
				result = (OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, false);
			}
			else
			{
				result = (OdDbPaperOrientationPE)Teigha.Core.Helpers.odrxCreateObjectInternal(p, true);
			}
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual bool paperOrientation(OdDbObject pObject)
		{
			bool result = TD_DbPINVOKE.OdDbPaperOrientationPE_paperOrientation(this.swigCPtr, OdDbObject.getCPtr(pObject));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult setPaperOrientation(OdDbObject pObject, bool bPaperOrientation)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPaperOrientationPE_setPaperOrientation(this.swigCPtr, OdDbObject.getCPtr(pObject), bPaperOrientation);
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		public virtual OdResult applyPaperOrientationTransform(OdDbObject arg0, OdDbViewport arg1)
		{
			OdResult result = (OdResult)TD_DbPINVOKE.OdDbPaperOrientationPE_applyPaperOrientationTransform(this.swigCPtr, OdDbObject.getCPtr(arg0), OdDbViewport.getCPtr(arg1));
			if (TD_DbPINVOKE.SWIGPendingException.Pending)
			{
				throw TD_DbPINVOKE.SWIGPendingException.Retrieve();
			}
			return result;
		}

		private object locker = new object();

		private HandleRef swigCPtr;
	}
}
